{extend name="base:base-add" /}
{block name="title"}
<title>添加权限</title>
{/block}
{block name="form"}
<form class="form form-horizontal" id="form-article-add">
    <div class="row clearfix">
        <label class="form-label col-xs-4 col-sm-2"><span class="c-red">*</span>权限组名：</label>
        <div class="form-controls col-xs-8 col-sm-4">
            <input type="text" class="input-text" value="{$gid|getGroupName}" disabled>
            <input type="hidden" class="input-text" value="{$gid}" id="gid" name="gid">
        </div>
    </div>
    <div class="row clearfix">
        <label class="form-label col-xs-4 col-sm-2">权限名称：</label>
        <div class="form-controls col-xs-8 col-sm-4">
            <input type="text" class="input-text" value="" placeholder="" id="name" name="name">
        </div>
    </div>
    <div class="row clearfix">
        <label class="form-label col-xs-4 col-sm-2">控制器：</label>
        <div class="form-controls col-xs-8 col-sm-4">
            <input type="text" class="input-text" value="" placeholder="" id="handler" name="handler">
        </div>
    </div>
    <div class="row clearfix">
        <label class="form-label col-xs-4 col-sm-2">描述：</label>
        <div class="form-controls col-xs-8 col-sm-9">
            <textarea name="description" cols="" rows="" class="textarea" placeholder="说点什么...最少输入10个字符"></textarea>
        </div>
    </div>
    <div class="row clearfix">
        <div class="col-xs-8 col-sm-9 col-xs-offset-4 col-sm-offset-2">
            <button class="btn btn-secondary radius add" type="button"><i class="Hui-iconfont">&#xe632;</i>
                保存
            </button>
        </div>
    </div>
</form>
{/block}
{block name="script"}
<script type="text/javascript">
    $(".add").click(function () {
        var postData = {};
        var data = $("form").serializeArray();
        $.each(data, function () {
            postData[this.name] = this.value
        });
        $.ajax({
            url: "/{$backendPrefix}/user/permission/add/{$gid}.html",
            type: "post",
            data: postData,
            "success": function (result) {
                var msgData = JSON.parse(result);
                if (msgData.status === true) {
                    layer.msg(msgData.message, {icon: 1, time: 1000}, function () {
                        window.parent.location.reload();
                    })
                } else {
                    layer.msg(msgData.message, {icon: 5, time: 2000})
                }
            }
        }, JSON);
    });
</script>
{/block}